#!/bin/bash
source ~/.bash_profile
# 59 23 * * * /目录/项目名/bin/crontab.sh

#############获取当前脚本层目录#########
sbin=`dirname "${BASH_SOURCE-$0}"`
sbin=`cd "$sbin"; pwd`
HOME_DIR="$sbin"/..

log_start=${HOME_DIR}/bin/log.sh
log_name=com.model.cn.MainJob

log_file=${HOME_DIR}/logs/info.log

ID=`ps -ef|grep "$log_name" |grep -v "$0" |grep -v "grep" |awk '{print $2}'`
if [ -z "$ID" ];then
	$log_start "restart"
echo "$(date +%Y-%m-%d" "%H:%M:%S) log restart" >> ${log_file} 
fi

###整点清理日志策略
logTime=$(date +%H%M)
if [ $logTime -eq 0000 ]
then
    today=$(date -d -24hour +%Y-%m-%d)
    cat ${HOME_DIR}/logs/catalina.out > ${HOME_DIR}/logs/catalina.out.${today}
    "" > ${HOME_DIR}/logs/catalina.out
    find ${HOME_DIR}/logs -type f -mtime +30 -delete 
fi